<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数参数默认值设置</title>
</head>
<body>
<script>
    //ES6 允许给函数参数赋初始值
    // 1. 形参初始值
    function fun(a,b,c=10) {//如果c没有赋默认值当函数调用时没有传c的值就会输出NAN
        return a*b*c;
    }
    let result=fun(1,2,3)
    console.log(result);

    // 2. 与解构赋值结合
    function connection({host, username, password, port=80}) {
        console.log(host,username,password,port);
    }
    connection({
        host:'127.0.0.1',
        username:'admin',
        password:'admin',
        port:9000
    })
</script>
</body>
</html>